package com.white.commonlib.adapter.recycle;

import android.support.v7.util.DiffUtil;

import java.util.List;

/**
 * Created by ytf on 2017/4/3 003.
 * Description: DiffUtil 里面用来比较两个数据集的差异
 */

public class DiffCallback<T> extends DiffUtil.Callback
{

    public List<T> oldData, newData;
    public DiffCallback(List<T> oldData, List<T> newData)
    {
        this.oldData = oldData;
        this.newData = newData;
    }

    @Override
    public int getOldListSize()
    {
        return oldData.size();
    }

    @Override
    public int getNewListSize()
    {
        return newData.size();
    }

    @Override
    public boolean areItemsTheSame(int oldItemPosition, int newItemPosition)
    {
        //根据需求判断两个数据集依次对比，如果明显不同的，就直接返回false刷新该item，由于此处是加载更多，所以肯定完全不同
        return true;
    }

    @Override
    public boolean areContentsTheSame(int oldItemPosition, int newItemPosition)
    {
        //由于此处是加载更多，所以肯定完全不同
        return false;
    }
}
